

paths.home='C:\Code\MatlabMPI\TIFprocessing';
paths.data='C:\Data\';




params.exp_name='FRET';

params.frames_pre=4;
params.frames_stim=4;
params.frames_post=2;
params.nbr_stimuli=8;
params.nbr_repetitions=3;
params.boundary=1;


params.frames_per_stim=params.frames_pre+params.frames_stim+params.frames_post;


[file_name_ch1]=uigetfile([paths.data params.exp_name '\*.tif'],'Select tif file that contains data of channel 1');
info_ch1=imfinfo([paths.data params.exp_name '\' file_name_ch1]);

[file_name_ch2]=uigetfile([paths.data params.exp_name '\*.tif'],'Select tif file that contains data of channel 2');
info_ch2=imfinfo([paths.data params.exp_name '\' file_name_ch2]);

if length(info_ch1)~=length(info_ch2)
    warndlg('Frames in channel 1 and channel 2 are not identical. Please choose different files.')
    break
end

number_of_frames=length(info_ch1);

%initialize the data array
data_ch1=zeros(info_ch1(1).Width,info_ch1(1).Height,number_of_frames);
data_ch2=zeros(info_ch2(1).Width,info_ch2(1).Height,number_of_frames);

for ind=1:number_of_frames
    data_ch1(:,:,ind)=imread([paths.data params.exp_name '\' file_name_ch1],ind);
    data_ch2(:,:,ind)=imread([paths.data params.exp_name '\' file_name_ch2],ind);
end

TPh.f1=figure(1);

set(TPh.f1,'color','k','menubar','none');
zero_value=-100;


ratio_mean=zeros(info_ch1(1).Width,info_ch1(1).Height);
for ind=1:number_of_frames
    clf;
    subplot(1,4,1)
    imagesc(data_ch1(:,:,ind))
    subplot(1,4,2)
    imagesc(data_ch2(:,:,ind))
    subplot(1,4,3)
    ratio=(data_ch1(:,:,ind)-zero_value)./(data_ch2(:,:,ind)-zero_value);
    ratio=ratio;
    ratio_mean=ratio_mean+ratio;
    imagesc(ratio)
    subplot(1,4,4)
    imagesc(ratio_mean)
    pause(0.01);
end







